<template>
	<view class="content">
		<view class="orderBody">
			<view class="orderHeader">
				<u--image :showLoading="true" :src="info.image[0]" width="158rpx" height="156rpx"
					radius="0"></u--image>
				<view class="rightInfo">
					<text class="moneny" :style="{color:$store.state.primaryColor}">￥<text class="moneny_num"
					:style="{color:$store.state.primaryColor}">{{info.salesprice || ''}}</text></text>
					<text class="text_content">已选择：{{info.name || ''}}</text>
					<view>
						<u-number-box v-model="req.nums" :min="1" :max="1"></u-number-box>
					</view>
				</view>
			</view>
			<view class="orderBottom" @click="show = true">
				<text class="title">备注</text>
				<view>
					<text>{{req.notes ? req.notes : '点击输入备注'}}</text>
					<u--image :showLoading="true" src="../../static/more.png" width="28rpx" height="28rpx"
						radius="0"></u--image>
				</view>
			</view>
		</view>

		<view class="priceInfo">
			<text class="title">价格明细</text>
			<view class="view">
				<text>商品总价</text>
				<text class="price" :style="{color:$store.state.primaryColor}">￥{{finally_salesprice || ''}}</text>
			</view>
		</view>

		<view class="priceInfo">
			<text class="title">支付方式</text>
			<view class="view">
				<view>
					<u--image :showLoading="true" src="../../static/Mine/wx.png" width="36rpx" height="36rpx"
						radius="0"></u--image>
					<text>微信</text>
				</view>
				<u-radio-group v-model="check">
					<u-radio shape="circle" :name="1" :activeColor="$store.state.primaryColor"></u-radio>
				</u-radio-group>
			</view>
		</view>

		<view class="payBody">
			<view class="paylet">
				<text class="paystatus">待支付：</text>
				<text :style="{color:$store.state.primaryColor}">￥<text class="moneny" :style="{color:$store.state.primaryColor}">{{finally_salesprice || 0}}</text></text>
			</view>
			<view class="payright">
				<button class="cancel" @click="cancel" :style="{'background':$store.state.cancelColor}">取消订单</button>
				<button class="pay" @click="linkUrl('/pages/Order/pay')" :style="{'background':$store.state.buttonColor}">去支付</button>
			</view>
		</view>

		<u-popup :show="show" @close="show = false" mode="bottom" :round="10" :closeable="true">
			<view class="popupBody">
				<text>订单备注</text>
				<textarea placeholder="选填,请和商家协商一致,付款后商家可见" v-model="req.notes"></textarea>
				<button @click="show = false" :style="{'background':$store.state.buttonColor}">确定</button>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		details
	} from '../../api/Home.js';
	export default {
		data() {
			return {
				show:false,
				check:1,
				info: {},
				req: {
					shop_id: uni.getStorageSync('shop_id') || 1, //门店id
					course_package_id: '', //套餐课程id
					course_package_type: '', //套餐课程类型
					nums: 1, //数量
					notes: '', //备注
				}
			}
		},
		onLoad(options) {
			this.details(options.id);
		},
		computed:{
			finally_salesprice(){
					return this.info.salesprice?Number(this.info.salesprice) * Number(this.req.nums):0
			}
		},
		methods: {
			/**
			@method 套餐详情
			**/
			async details(Id = null) {
				try {
					const res = await details({
						shop_id:uni.getStorageSync('shop_id') || 1,
						id: Id
					});
					this.info = {
						...res.data
					};
				} catch (err) {
					//TODO handle the exception
					console.log(err);
				}
			},
			linkUrl(e) {
				this.req = {
					...this.req,
					...{
						shop_id: uni.getStorageSync('shop_id') || 1, //门店id
						course_package_id: this.info.id, //套餐课程id
						course_package_type: this.info.type, //套餐课程类型
						money:this.finally_salesprice
					}
				};
				uni.navigateTo({
					url: e+`?payinfo=${JSON.stringify(this.req)}`
				});
			},
			cancel(){
				      uni.navigateBack({
				        delta: 1 // 默认值是1，表示返回的页面层数
				      });
			}
		}
	}
</script>

<style>
	page {
		background-color: #f7f7f7;
	}
</style>
<style scoped lang="scss">
	button::after{ border: none;} 
	.content {
		padding: 20rpx;

		.popupBody {
			padding: 30rpx 30rpx 50rpx 30rpx;

			text {
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				font-size: 36rpx;
				color: #333333;
				display: block;
				text-align: center;
			}

			textarea {
				width: auto;
				height: 200rpx;
				padding: 30rpx;
				margin: 30rpx auto;
				background-color: #eeeeee;
				border-radius: 20rpx;
			}

			button {

				width: 100%;
				font-size: 31rpx;
				border-radius: 50rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				// background-color: #267ffe;
				color: #fff;
				border: none;
				outline: none;
			}
		}

		.payBody {
			width: 100%;
			height: auto;
			padding-top: 30rpx;
			padding-bottom: 30rpx;
			background-color: #fff;
			position: fixed;
			bottom: 0rpx;
			left: 0rpx;
			display: flex;
			justify-content: space-around;
			align-items: center;

			.paylet {
				.paystatus {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #202020;
				}

				.moneny {
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 40rpx;
					color: #029CFE;
				}

				text {
					font-family: '.SFNS, SFNS';
					font-weight: 400;
					font-size: 28rpx;
					color: #029CFE;
				}
			}

			.payright {
				display: flex;
				align-items: center;

				.cancel {
					width: 200rpx;
					font-size: 31rpx;
					border-radius: 50rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					margin: 0rpx;
					background-color: #efefef;
				}

				.pay {
					margin: 0rpx;
					width: 200rpx;
					font-size: 31rpx;
					border-radius: 50rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					margin: 0rpx;
					margin-left: 30rpx;
					// background-color: #267ffe;
					color: #fff;
					border: none;
					outline: none;
				}
			}
		}

		.priceInfo {
			background-color: #fff;
			padding: 25rpx 25rpx 35rpx 25rpx;
			border-radius: 15rpx;
			margin-top: 20rpx;
			margin-bottom: 20rpx;

			.title {
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				font-size: 32rpx;
				color: #333333;
			}

			/deep/ .u-radio-group {
				flex: 0;
			}

			.view {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 20rpx;

				view {
					display: flex;
					align-items: center;

					text {
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 28rpx;
						color: #222426;
						margin-left: 20rpx;
					}
				}

				text {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #222426;
				}

				.price {
					font-family: PingFangSC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #029CFE;
				}
			}
		}

		.orderBody {
			background-color: #fff;
			padding: 25rpx;
			border-radius: 15rpx;

			.orderHeader {
				display: flex;

				.rightInfo {
					width: 90%;
					padding-left: 20rpx;

					view {
						display: flex;
						justify-content: flex-end;
					}

					.moneny {
						font-family: '.SFNS, SFNS';
						font-weight: 400;
						font-size: 24rpx;
						color: #029CFE;
					}

					.moneny_num {
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						font-size: 36rpx;
						color: #029CFE;
					}

					.text_content {
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #202020;
						display: block;
						margin-top: 10rpx;
						margin-bottom: 20rpx;
					}
				}

			}

			.orderBottom {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 30rpx;

				.title {
					font-family: PingFangSC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #222426;
				}

				view {
					display: flex;
					align-items: center;
				}

				text {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #202020;
				}
			}
		}
	}
</style>